abs
Absolute value
abs()
function returns the absolute value of a number.
<?php echo ( abs ( 6.7 ) ) ; echo ( abs ( - 3 ) ) ; echo ( abs ( 3 ) ) ; ?>
Try it yourself
abs ( x )
parameter | describe |
---|---|
x | Required. A number. |
Returns the absolute value of parameter x . If the parameter x is float, the returned type is also float, otherwise the integer is returned (because float usually has a larger range of values than integer).